<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<span mat-dialog-title class="title">Export API</span>

<mat-dialog-content class="content">
  <mat-tab-group [(selectedIndex)]="selectedTabIndex">
    <!-- Tab - Export Json -->
    <mat-tab label="Gravitee API definition">
      <div *ngIf="exportJsonFrom" class="content__json" [formGroup]="exportJsonFrom">
        <mat-form-field class="content__json__select">
          <mat-label>Target APIM version</mat-label>
          <mat-select #exportVersionSelect formControlName="exportVersion" name="exportVersion">
            <mat-select-trigger *ngIf="getJsonOptions(exportVersionSelect.value) as option">
              {{ option.label || '' }} <span *ngIf="option.isDeprecated" class="gio-badge-error">Deprecated</span>
            </mat-select-trigger>

            <mat-option *ngFor="let option of jsonOptions" [value]="option.id">
              {{ option.label }} <span *ngIf="option.isDeprecated" class="gio-badge-error">Deprecated</span>
            </mat-option>
          </mat-select>
        </mat-form-field>

        <h5>Include additional data</h5>
        <div class="content__options" formGroupName="options">
          <mat-checkbox class="content__options__option" *ngFor="let option of jsonOptionsCheckbox" [formControlName]="option.id">
            {{ option.label }}
          </mat-checkbox>
        </div>
      </div>
    </mat-tab>
    <!-- Tab - Export CRD -->
    <mat-tab>
      <ng-template mat-tab-label>
        <mat-icon class="content__crd__label__icon" svgIcon="gio:kubernetes"></mat-icon>
        CRD API Definition
      </ng-template>

      <gio-banner-info>
        <div>
          Export your API Definition as a Kubernetes Custom Resource Definition and start using our Kubernetes Operator to manage your API
          declaratively.
          <a
            href="https://documentation.gravitee.io/apim/getting-started/install-guides/install-on-kubernetes"
            target="_blank"
            rel="noopener noreferrer"
          >
            Link to documentation <mat-icon class="content__crd__link__icon" svgIcon="gio:external-link"></mat-icon>
          </a>
        </div>
      </gio-banner-info>
    </mat-tab>
  </mat-tab-group>
</mat-dialog-content>

<mat-dialog-actions align="end" class="actions">
  <button mat-flat-button [mat-dialog-close]="false">Cancel</button>
  <button color="primary" mat-raised-button (click)="onExport()" data-testid="api_info_export_api">Export</button>
</mat-dialog-actions>
